Skip to content

apply staking multiplier to guests impl#80

Merged
Kaylahray merged 5 commits into
learnault:mainfrom
Birdmannn:feat-#55
Jun 3, 2026
Merged

apply staking multiplier to guests impl#80
Kaylahray merged 5 commits into
learnault:mainfrom
Birdmannn:feat-#55

Conversation

@Birdmannn
Copy link
Copy Markdown
Contributor

Quest Engine: Staking Multiplier Implementation

Overview

Implemented staking multiplier feature that applies a boost to learner payouts based on their stake in the StakeVault contract.

Changes

1. Contract Implementation

Files:

  • contracts/quest-engine/src/lib.rs
  • contracts/quest-engine/src/types.rs

Added:

  • StakeVaultClient interface to fetch multiplier from StakeVault contract
  • StakeVault address to initialization parameters and storage
  • Multiplier logic in review_submission function

Multiplier Logic:

  • Fetches multiplier from StakeVault (basis points: 100 = 1.0x, 120 = 1.2x)
  • Applies multiplier to base learner amount (after 15% fee)
  • Caps boosted amount to available funds to prevent overflow
  • Formula: boosted_amount = (base_amount * multiplier) / 100

Note: Current implementation caps boost to available quest funds. In production, employers should fund quests accounting for potential multipliers, or boosts should come from a separate authorized reward pool contract.

2. Tests

File: contracts/quest-engine/src/test.rs

Added:

  • MockStakeVault contract returning 100 (1.0x) by default
  • MockStakeVaultWithMultiplier returning 120 (1.2x)
  • setup_with_multiplier() helper function
  • 4 new tests:
    • test_review_submission_with_no_multiplier - Verifies 1.0x multiplier
    • test_review_submission_with_120_multiplier - Verifies 1.2x multiplier (capped)
    • test_review_submission_with_80_multiplier - Verifies 1.0x baseline
    • test_multiplier_math_correctness - Validates calculation logic

3. Updated Initialization

Breaking Change: initialize() now requires stake_vault parameter:

pub fn initialize(
    env: Env,
    admin: Address,
    token: Address,
    reward_pool: Address,
    stake_vault: Address, // NEW
)

Math Examples

Reward Fee (15%) Base Multiplier Calculated Actual Payout
1000 150 850 100 (1.0x) 850 850
1000 150 850 120 (1.2x) 1020 850 (capped)
5000 750 4250 120 (1.2x) 5100 4250 (capped)

Verification

✅ All tests pass (111 total across all contracts)
✅ Clippy clean
✅ Formatting correct
✅ Wasm builds successfully
✅ CI ready

Future Enhancements

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@Birdmannn Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kaylahray Kaylahray merged commit 3d5e04a into learnault:main Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[QuestEngine] Apply staking multiplier to quests

2 participants